package cn.gmy.progect1;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

import org.apache.hadoop.io.WritableComparable;

public class PhoneExcelWritable implements WritableComparable<PhoneExcelWritable>{
	private String month;
	private String flag;
	private String name;
	private String phone;
	private int duration;
	
	
	public PhoneExcelWritable() {
		
	}

	public PhoneExcelWritable(String month, String flag,String name,String phone, int duration) {
		this.month = month;
		this.flag=flag;
		this.name=name;
		this.phone = phone;
		this.duration = duration;
	}	
	
	@Override
	public String toString() {
		return  month + "\t" +flag+ "\t" +name+ "\t" + phone + "\t" + duration;
	}

	@Override
	public void readFields(DataInput in) throws IOException {
		month=in.readUTF();
		flag=in.readUTF();
		name=in.readUTF();
		phone=in.readUTF();
		duration=in.readInt();
	}


	@Override
	public void write(DataOutput out) throws IOException {
		out.writeUTF(month);
		out.writeUTF(flag);
		out.writeUTF(name);
		out.writeUTF(phone);
		out.writeInt(duration);
	}

	@Override
	public int compareTo(PhoneExcelWritable o) {
		int m = this.month.compareTo(o.month);
		if (m==0) {
			m=this.flag.compareTo(o.flag);
			if (m==0) {
				m = -(this.duration-o.duration);			
			}
		}
		return m;
	}
	
	//getter,setter方法
	public String getMonth() {
		return month;
	}


	public void setMonth(String month) {
		this.month = month;
	}


	public String getPhone() {
		return phone;
	}


	public void setPhone(String phone) {
		this.phone = phone;
	}


	public int getDuration() {
		return duration;
	}


	public void setDuration(int duration) {
		this.duration = duration;
	}


	public String getName() {
		return name;
	}


	public void setName(String name) {
		this.name = name;
	}


	public String getFlag() {
		return flag;
	}


	public void setFlag(String flag) {
		this.flag = flag;
	}
}
